package org.zhenggn.designpattern.chain;

/**
 * Created by zhenggn on 2017/5/3.
 */
public class GeneralManager extends Handler {
    public String handleFeeRequest(String user, double fee) {
        Context context = new Context();
        context.setStr("66667777");

        User user111 = new User();
        user111.setAge(23);
        user111.setAddress("郑家大");
        user111.setTelphone(1861256);
        context.setUser(user111);

        MyThreadLocal.set(context);

        String str = "";
        if (fee >= 1000) {
            if ("小李".equals(user)) {
                str = "总经理同意" + user + "聚餐费用" + fee + "元的请求";
                return this.getSuccessor().handleFeeRequest(user, fee);
            } else {
                str = "总经理不同意" + user + "聚餐费用" + fee + "元的请求";
            }
        } else {
            if (this.getSuccessor() != null) {
                return this.getSuccessor().handleFeeRequest(user, fee);
            }
        }

        return str;
    }
}
